﻿using JobRecruitment.Entities;
using JobRecruitment.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace JobRecruitment.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class JobController : ControllerBase
    {
        public JobRecruitmentContext _context { get; }

        public JobController(JobRecruitmentContext context)
        {
            _context = context;
        }

        // GET: api/Job
        [HttpGet]
        public Dictionary<string, object> Get()
        {
            Dictionary<string, object> dicRes = new();

            JobViewModel jobsViewModel = new(_context);
            CompanyViewModel CompanyViewModel = new(_context);
            RequriementFilterViewModel requriementFiltersViewModel = new(_context);

            var jobsViews = jobsViewModel.GetJobs();
            var companys = CompanyViewModel.GetCompanys();
            var requriements = requriementFiltersViewModel.GetRequriement();

            dicRes.Add("jobViews", jobsViews);
            dicRes.Add("companyViews", companys);
            dicRes.Add("requriementViews", requriements);
            return dicRes;
        }

        // GET: api/Job/5
        [HttpGet("{id}")]
        public Job Get(int id)
        {
            return new JobViewModel(_context).GetJobById(id);
        }

        //// POST: api/Job
        //[HttpPost]
        //public void Post([FromBody] string value)
        //{
        //}

        //// PUT: api/Job/5
        //[HttpPut("{id}")]
        //public void Put(int id, [FromBody] string value)
        //{
        //}

        //// DELETE: api/Job/5
        //[HttpDelete("{id}")]
        //public void Delete(int id)
        //{
        //}
    }
}
